﻿using System;
using System.Linq;

namespace IGolovkine.AoA.Tcp.Channels.Http
{
    [Serializable]
    public class HttpEnvelope 
    {
        public static readonly HttpEnvelope Empty = new HttpEnvelope(new Message[0]);

        private readonly Message[] _messages;
        public HttpEnvelope(Message[] messages)
        {
            _messages = messages;
        }

        public Message[] Messages
        {
            get { return _messages; }
        }

        public int GetConnectionDataLength()
        {
            return _messages.OfType<TcpConnectionData>().Sum(m => m.Data.Length);
        }
    }
}
